#include "Transform.h"
Transform::Transform():
	Component("Transform"),
	m_translation(0.0f,0.0f,0.0f),
	m_rotation(0.0f,0.0f,0.0f),
	m_scale(1.0f,1.0f,1.0f)
{
}
Transform::Transform(float* _position):
	Component("Transform"),
	m_translation(_position),
	m_rotation(0.0f, 0.0f, 0.0f),
	m_scale(1.0f, 1.0f, 1.0f)
{
}
Transform::Transform(std::vector<float>position):
	Component("Transform"),
	m_translation(position[0],position[1],position[2]),
	m_rotation(0.0f, 0.0f, 0.0f),
	m_scale(1.0f, 1.0f, 1.0f)
{
}
Transform::~Transform()
{
}
void Transform::Translate(float directionX, float directionY, float directionZ)
{
	DirectX::XMFLOAT3 newTranslation(directionX, directionY, directionZ);
	m_translation = newTranslation;
}
void Transform::Rotate(float radianX, float radianY, float radianZ)
{
	DirectX::XMFLOAT3 newRotation(radianX, radianY, radianZ);
	m_rotation = newRotation;
}
void Transform::Scale(float scaleTimesX, float scaleTimesY, float scaleTimesZ)
{
	DirectX::XMFLOAT3 newScale(scaleTimesX, scaleTimesY, scaleTimesZ);
	m_scale = newScale;
}
DirectX::XMFLOAT3 Transform::GetPosition()
{
	return m_translation;
}
DirectX::XMFLOAT3 Transform::GetRotation()
{
	return m_rotation;
}
DirectX::XMFLOAT3 Transform::GetScale()
{
	return m_scale;
}
DirectX::XMMATRIX Transform::GetWorldMatrix()
{
	DirectX::XMVECTOR translationVector = DirectX::XMLoadFloat3(&m_translation);
	DirectX::XMVECTOR rotationVector = DirectX::XMLoadFloat3(&m_rotation);
	DirectX::XMVECTOR scaleVector = DirectX::XMLoadFloat3(&m_scale);
	DirectX::XMMATRIX translationMatrix = DirectX::XMMatrixTranslationFromVector(translationVector);
	DirectX::XMMATRIX rotationMatrix = DirectX::XMMatrixRotationRollPitchYawFromVector(rotationVector);
	DirectX::XMMATRIX scaleMatrix = DirectX::XMMatrixScalingFromVector(scaleVector);
	DirectX::XMMATRIX worldMatrix = scaleMatrix*rotationMatrix*translationMatrix;
	return worldMatrix;
}
DirectX::XMMATRIX Transform::GetLocalMatrix()
{
	DirectX::XMVECTOR rotationVector = DirectX::XMLoadFloat3(&m_rotation);
	DirectX::XMVECTOR scaleVector = DirectX::XMLoadFloat3(&m_scale);
	DirectX::XMMATRIX rotationMatrix = DirectX::XMMatrixRotationRollPitchYawFromVector(rotationVector);
	DirectX::XMMATRIX scaleMatrix = DirectX::XMMatrixScalingFromVector(scaleVector);
	DirectX::XMMATRIX localMatrix = scaleMatrix*rotationMatrix;
	return localMatrix;
}